summaryrefslogtreecommitdiff
path: root/src/pages/[locale]/news/index.astro
diff options
context:
space:
mode:
authorJoe Carstairs <65492573+Sycamost@users.noreply.github.com>2023-12-14 22:39:57 +0000
committerJoe Carstairs <65492573+Sycamost@users.noreply.github.com>2024-01-12 08:28:52 +0000
commita783b4a6858f25a1453d77931926ba93bc0b7052 (patch)
tree3da5677a921e9f0fc39c9452394ec923a15f0a67 /src/pages/[locale]/news/index.astro
parent4710fb1c87d5926f630716f003e736e019b3fcf5 (diff)
Reorder news (#42)
* Reslugs news items * Fixes typo in getMostRecentNewsItem() * Fixes typo in newUtils.getDate() * Sorts news index from most recent to oldest
Diffstat (limited to 'src/pages/[locale]/news/index.astro')
-rw-r--r--src/pages/[locale]/news/index.astro6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/pages/[locale]/news/index.astro b/src/pages/[locale]/news/index.astro
index 37e7dd6..112f87b 100644
--- a/src/pages/[locale]/news/index.astro
+++ b/src/pages/[locale]/news/index.astro
@@ -5,12 +5,14 @@ import Page from '$layouts/Page.astro';
import { getLocaleFromPathOrThrow } from '$lib/getLocaleFromPath';
import localeStaticPaths from '$lib/localeStaticPaths';
import { getCollection } from 'astro:content';
-import { isNewsItemInLocale } from '$lib/newsUtils';
+import { isBefore, isNewsItemInLocale } from '$lib/newsUtils';
import NewsIndex from '$components/NewsIndex/NewsIndex.astro';
const allNews = await getCollection('news');
const locale = getLocaleFromPathOrThrow(Astro.url.pathname);
-const allNewsInLocale = allNews.filter((item) => isNewsItemInLocale(item, locale));
+const allNewsInLocale = allNews
+ .filter((item) => isNewsItemInLocale(item, locale))
+ .sort((a, b) => (isBefore(a, b) ? 1 : isBefore(b, a) ? -1 : 0));
const t = translate(locale);
export async function getStaticPaths() {